cmake_minimum_required(VERSION 3.13)
project(mysql_binlog C)

set(CMAKE_C_STANDARD 99)

# 您需要更新下面的三个库路径即可
set(MYSQL_INCLUDE     /usr/local/mysql/include)      # 您系统的MySQL头文件路径
set(MYSQL_LIBRARY_DIR /usr/local/mysql/lib)          # 您系统的MySQL库文件路径
set(CURL_DIR          /usr/local/Cellar/curl/7.58.0) # 您系统的curl安装路径

set(
    ALL_PERMISSIONS
    OWNER_WRITE OWNER_READ OWNER_EXECUTE
    GROUP_READ GROUP_WRITE GROUP_EXECUTE
    WORLD_READ WORLD_WRITE WORLD_EXECUTE
)

include_directories(
    .
    src
    src/json
    src/xml
    src/tool
    src/binlog
    ${CURL_DIR}/include
    ${MYSQL_INCLUDE}
)

link_directories( ${MYSQL_LIBRARY_DIR} ${CURL_DIR}/lib )

aux_source_directory(.          MAIN_SOURCE)
aux_source_directory(src/json   JSON_SOURCE)
aux_source_directory(src/xml    XML_SOURCE)
aux_source_directory(src/tool   TOOL_SOURCE)
aux_source_directory(src/binlog BINLOG_SOURCE)

add_executable(
    mbinlogmq
    main.c
    ${MAIN_SOURCE} ${JSON_SOURCE} ${XML_SOURCE} ${TOOL_SOURCE} ${BINLOG_SOURCE}
)

target_link_libraries(mbinlogmq mysqlclient pthread curl)


install(TARGETS mbinlogmq RUNTIME DESTINATION /usr/local/bin)
install(FILES conf/binlog.xml DESTINATION /etc/mbinlogmq)
install(DIRECTORY DESTINATION /var/log/mbinlogmq DIRECTORY_PERMISSIONS ${ALL_PERMISSIONS})